﻿@using OBUCare.Core.Models;
@using OBUCare.Web.Infrastructure;
@using OBUCare.Web.Models;
@using OBUCare.Core.BL;
@model ObuInfo
@{
    var operatorInfo = UIUtility.GetCurrentUser();

    var menuNames = UIUtility.getMenuName(Request.RawUrl);

    string AgentNo = UIUtility.getAgentByModule(operatorInfo, menuNames.ToString());
}
@if (Model.ObuBaseInfo != null)
{
    int i = 0;
    i = DateTime.Compare(DateTime.Now, new OBUCare.Web.Controllers.RepairOrdersController().GetLifeDate(Model.ObuBaseInfo.OBU_NO, Model.ObuBaseInfo.REGISTE_DATE));

    string spec_name = Model.ObuBaseInfo.SPEC_NAME;
    ObuDropDownListHlper ddlHelper = new ObuDropDownListHlper();
    OBUCareOrderMgr obumgr = new OBUCareOrderMgr();
    <div style="width: 100%">
        @* <div>
                基本信息
            </div>*@
        <div>
            <table style="width: 100%">
                <tr>
                    <td width="20%">
                        受理营业厅：
                    </td>
                    @if (AgentNo != "")
                    {
                        <td width="30%">
                            @Html.DisplayFor(m => m.OperatorInfo.AgentName)
                        </td>
                    }
                    else
                    {
                        <td width="30%">
                            @Html.Telerik().DropDownList().ClientEvents(events => events.OnLoad("drop_onload")).Name("Agent").HtmlAttributes(new { @style = "Width:210px;" })
                        </td>
                    }
                    <td width="20%">
                        厂家：@Html.Hidden("SUPPLIER", Model.ObuBaseInfo.SUPPLIER, new { width = "0px" })
                    </td>
                    <td width="30%">
                        @if (Model.ObuBaseInfo.SUPPLIER == null)
                        {
                            @* @Html.Telerik().DropDownList().Name("Supplier").ClientEvents(events => events.OnChange("supplier_onchange")).BindTo(ddlHelper.GetSuppliers(UIConstants.AllItems, false))*@
                            @Html.Telerik().DropDownList().Name("Supplier").BindTo(ddlHelper.GetSuppliers("请选择", true, new KeyValuePair<string, string>("请选择", "请选择"))).CascadeTo("Specs")
                        }
                        else
                        {
                            @Html.DisplayFor(m => m.ObuBaseInfo.SUPPLIER)
                            @Html.Hidden("SUPPLIER_ID", Model.ObuBaseInfo.SUPPLIERS_ID, new { width = "0px" })
                        }
                    </td>
                </tr>
                <tr>
                    <td>
                        标签型号：@Html.Hidden("SPEC_NAME", Model.ObuBaseInfo.SPEC_NAME == null ? "" : Model.ObuBaseInfo.SPEC_NAME, new { width = "0px" })
                    </td>
                    <td>
                        @if (Model.ObuBaseInfo.SPEC_NAME == null)
                        {
                            @*  @Html.Telerik().DropDownList().Name("Specs").ClientEvents(events => events.OnLoad("specs_onload"))*@
                            @Html.Telerik().DropDownList().Name("Specs").HtmlAttributes(new { @style = "Width:230px;" }).DataBinding(binding => binding.Ajax().Select("_GetSpecs", "RepairOrders"))
                        }
                        else
                        {
                            @Html.DisplayFor(m => m.ObuBaseInfo.SPEC_NAME)
                            @Html.Hidden("SPEC_ID", Model.ObuBaseInfo.SPEC_ID, new { width = "0px" })
                        }
                    </td>
                    <td>
                        标签号：
                        @Html.Hidden("OBU_NO", Model.ObuBaseInfo.OBU_NO, new { width = "0px" })
                    </td>
                    <td>
                        @Html.DisplayFor(m => m.ObuBaseInfo.OBU_NO)
                    </td>
                </tr>
                <tr>
                    <td>
                        车牌号：
                        @Html.Hidden("VEHICLE_PLATE_NO", Model.ObuBaseInfo.VEHICLE_PLATE_NO, new { width = "0px" })
                    </td>
                    <td>
                        @Html.DisplayFor(m => m.ObuBaseInfo.VEHICLE_PLATE_NO)
                    </td>
                    <td>
                        车型： @Html.Hidden("VEHICLE_CLASS", Model.ObuBaseInfo.VEHICLE_CLASS, new { width = "0px" })
                    </td>
                    <td>
                        @Html.Label(obumgr.GetVehicelClass(Model.ObuBaseInfo.VEHICLE_CLASS))
                    </td>
                </tr>
                <tr>
                    <td>
                        客户编号：
                        @Html.Hidden("USER_NO", Model.ObuBaseInfo.USER_NO, new { width = "0px" })
                    </td>
                    <td>
                        @Html.DisplayFor(m => m.ObuBaseInfo.USER_NO)
                    </td>
                    <td>
                        发行日期：
                        @Html.Hidden("REGISTER_DATE", Model.ObuBaseInfo.REGISTE_DATE, new { width = "0px", @id = "CheckDate", Date = @i })
                    </td>
                    <td id="registeTime">
                        @Html.DisplayFor(m => m.ObuBaseInfo.REGISTE_DATE)
                    </td>
                </tr>
                <tr>
                    <td>
                        所有人：
                        @Html.Hidden("OWNER_NAME", Model.ObuBaseInfo.USER_NAME, new { width = "0px" })
                    </td>
                    <td>
                        @Html.DisplayFor(m => m.ObuBaseInfo.USER_NAME)
                    </td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        </div>
        <div>
            <img src="@Url.Content("~/Content/images/blueline1.png")" width="805" height="21">
        </div>
    </div>
   
}
<script type="text/javascript">
    function supplier_onchange(e) {
        var supplier = $('#Supplier').data('tDropDownList');
        var specs = $('#Specs').data('tDropDownList');
        $.post("/RepairOrders/_GetSpecs", { "supplierID": supplier.value() }, function (data) {
            specs.dataBind(data);
            specs.select(0);
        })
    }

    function specs_onload(e) {
        var supplier = $('#Supplier').data('tDropDownList');
        var specs = $('#Specs').data('tDropDownList');
        $.post("/RepairOrders/_GetSpecs", { "supplierID": supplier.value() }, function (data) {
            specs.dataBind(data);
            specs.select(0);
        })
    }


    function drop_onload(e) {
        var drop = $('#Agent').data('tDropDownList');
        $.post("/RepairOrders/_GetAgentCR", { "AgentType": "全部", "AgentNo": "@AgentNo" }, function (data) {
            drop.dataBind(data);
            drop.select(0);
            if ("@AgentNo" != "") {
                drop.disable();
            }
        })
    }
</script>
